import { get } from '@/utils/http'
import config from '@/config/api'

// 影院列表数据
export const getCitiesInfo = async () => {
  const ret = await get(config.getCitiesInfo)
  let cityData = ret.data.cities
  // let indexList = ['A', 'B', 'C']
  let outData = {}
  let indexList = []

  for (let i = 65; i <= 90; i++) {
    indexList.push(String.fromCharCode(i))
  }

  indexList.forEach(item => {
    outData[item] = cityData.filter(({ pinyin }) => pinyin.slice(0, 1).toUpperCase() === item)
    if (outData[item].length == 0) delete outData[item]
  })

  return outData
}
